package chapter03

/**
 * @program lu-scala01
 * @description: 特征叠加覆盖（后面的覆盖前面的）
 *  类图
 *    - CategoryBall15 -> Ball15
 *    - ColorBall15 -> Ball15
 *    - LuFootBall15
 *  实际执行过程：LuFootBall15 -> ColorBall15 -> CategoryBall15 -> Ball15
 * @author: zhanglu
 * @create: 2022-03-27 18:49:00
 */
object C15_TraitOverlying2 {

  def main(args: Array[String]): Unit = {
    val ball = new LuFootBall15
    println(ball.describe())
  }

}

//定义球类特征
trait Ball15{
  def describe(): String = "ball"
}

//定义颜色特征
trait ColorBall15 extends Ball15{
  var color: String = "red"
  override def describe(): String = color + "-" + super.describe()
}

//定义种类特征
trait CategoryBall15 extends Ball15{
  var category: String = "foot"

  override def describe(): String = category + "-" + super.describe()
}

//自定义的球类
class LuFootBall15 extends CategoryBall15 with ColorBall15{
  override def describe(): String = "lu ball is a " + super.describe()
}


